package com.zhku.onlineshop.Servlet;

import com.zhku.onlineshop.Pojo.Result;
import com.zhku.onlineshop.Pojo.User;
import com.zhku.onlineshop.Service.LogginService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;



@Slf4j
@RestController
public class LogginServlet {
    @Autowired
    private LogginService logginService;


    @PostMapping("/loggin1")
    public Result loggin1(@RequestBody User user) {
        log.info("顾客登录");
        User user1 = logginService.loggin(user);
        if (user1 != null) {
            return Result.success(user1);
        } else {
            return Result.error("用户不存在");
        }
    }
        @PostMapping("/loggin2")
        public Result loggin2(@RequestBody User user) {
            log.info("店铺登录");
            User user1 = logginService.loggin1(user);
            if (user1 != null) {
                return Result.success(user1);
            } else {
                return Result.error("用户不存在");
            }
    }
}

